import {
	get,
	post
} from '../../utils/request.js'
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		list: [],
		isEmpty: true
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function(options) {
		this.getHomeGoodsData()
		// this.jusEmpty()
	},
	onShow() {
		this.getHomeGoodsData()
	},
	async getHomeGoodsData() {
		const allCollectGoodsList = await get('/collect/getCollectGoodsList')
		// console.log(allCollectGoodsList)
		this.setData({
			list: allCollectGoodsList.data
		})
		const len = this.data.list.length
		if (len > 0) {
			this.setData({
				isEmpty: true
			})
		} else {
			this.setData({
				isEmpty: false
			})
		}
	},
	goToDetail (e) {
		let id = e.currentTarget.dataset.id
		// console.log(id)
		wx.navigateTo({
			url: `/pages/goodsdetail/goodsdetail?id=${id}`
		})
	}
})
